package wikichat.android.intelimed;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class WikiActivity extends Activity {
	
	Cursor cursor;
	Button bt_back;
	Intent intent, changePage;
	TextView screen;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.wikipage);
		
		SQLiteHelper myHelper = new SQLiteHelper(WikiActivity.this);
		
		myHelper.createDataBase();
		myHelper.openDataBase();
		
		SQLiteDatabase base = myHelper.getReadableDatabase();

		String texto;
		intent = getIntent();
		if(intent != null)
			texto = intent.getStringExtra("text");
		
		cursor = base.query("Content", null, null, null, null, null, null);
		cursor.moveToFirst();
		
		screen = (TextView)findViewById(R.id.wikiView);
		screen.setText(cursor.getString(cursor.getColumnIndex("Wiki")));
		
		base.close();
		myHelper.close();

		bt_back = (Button)findViewById(R.id.wikiBack);
		bt_back.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				changePage = new Intent(WikiActivity.this, WIKICHATActivity.class);
				startActivity(changePage);
			}
		});
		
	}

}
